/*
 * Copyright (C) 2020 Agrui
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef POLICY_SERVICE_H
#define POLICY_SERVICE_H

#include <types.h>
#include <MessageHandler.h>
#include <RegistrantList.h>
#include <Bundle.h>
#include <ArrayList.h>
#include <Action.h>
#include <Event.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef void (*onLoadEvent)(ArrayList* eventList);
typedef void (*onLoadPolicy)(char* rule, int size);

#define MAX_EXPRESSION_LEN      500


typedef struct PolicyService_TAG {
    ArrayList* mEventList;
    char mPolicy[MAX_EXPRESSION_LEN];
    Handler* mHandler;
    void* mExprVarList;
    void* mExpression;
    onLoadEvent mEventCb;
    onLoadPolicy mPolicyCb;
    Action* mAction;

} PolicyService;

PolicyService* newPolicyService(onLoadEvent loadEvent, onLoadPolicy loadPolicy );
void deletePolicyService(PolicyService* service);

Event* getPolicyEvent(PolicyService* service, const char* name);

void setAction(PolicyService* service, Action* action);

#ifdef __cplusplus
}
#endif

#endif
